package com.bweab.dao.impl.en;

import com.bweab.dao.api.En.UserTbDaoEnInterface;
import com.bweab.dao.base.BaseDao;
import com.bweab.pojo.en.UsersTbPageEn;

import java.util.List;

/***
 * 用户页面的相关操作
 */
public class UserTbDaoEnInterfaceImpl extends BaseDao<UsersTbPageEn> implements UserTbDaoEnInterface {
//页面类的查询相关操作


    /**
     * like查询
     * @param queryC like查询条件
     * @param page  第几页
     * @param pageSize 页面大小
     * @return 返回 UsersTbPageEn集合
     */

    @Override
    public List<UsersTbPageEn> getUserInfoByLike(String queryC, int page, int pageSize) {
        //准备like查询语句
        String sql="select\n" +
                "    (select count(*) from users_tb where user_name like ?) totalCount,\n" +
                "    users_tb.user_id userId,\n" +
                "    users_tb.user_name userName,\n" +
                "    users_tb.user_password userPassword,\n" +
                "    users_tb.user_sex userSex,\n" +
                "    users_tb.user_xh userXh,\n" +
                "    users_tb.user_phone userPhone,\n" +
                "    users_tb.user_status userStatus\n" +
                "from\n" +
                "    users_tb\n" +
                "where\n" +
                "    user_name like ?\n" +
                "\n" +
                "limit ?,?";
        int start;
        //计算起始位置

        start= (page-1) * pageSize;



        List<UsersTbPageEn> pageEnList = queryList(sql, UsersTbPageEn.class,queryC,queryC,start,pageSize);
        System.out.println(pageEnList);
        return pageEnList;
    }


}
